package com.ch.dream.base;

import java.util.HashMap;
import java.util.Map;

import android.app.ProgressDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.ch.dream.R;
import com.ch.dream.net.MyHttpAPI;

public class BaseLogic {
	protected BaseActivity activity;
	protected Map<Integer,View> views;
	protected int layoutId;
	protected MyHttpAPI myHttpApi;
	protected ProgressDialog progressDialog;
	public BaseLogic(){
		
	}
	
	public BaseLogic(BaseActivity activity) {
		initActivity(activity);
	}
	public BaseLogic(BaseActivity activity,int layoutId) {
		initActivity(activity);
		activity.setContentView(layoutId);
	}
	
	public void setViews(int layoutId){
		this.layoutId = layoutId;
		LayoutInflater iInflater = activity.getLayoutInflater();
		RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
		activity.addContentView(activity.baseLayout, layoutParams);
		ViewGroup mainView=(ViewGroup) iInflater.inflate(this.layoutId,null);
		layoutParams.addRule(RelativeLayout.BELOW, R.id.titleBar);
		activity.baseLayout.addView(mainView, layoutParams);
	}
	
	private void initActivity(BaseActivity activity){
		this.activity = activity;
		views = new HashMap<Integer, View>();
	}
}
